/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ucmconfchecker.pImplementation;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import ucmconfchecker.NamedObject;

/**
 *
 * @author Administrador
 */
public class EClass extends NamedObject{
    
    private Set<EMethod> methods;
    
    public EClass(String name){
        super(name);
    }
    public void addMethod(EMethod method){
        if(methods==null){
            methods=new HashSet<EMethod>();
        }
        methods.add(method);
    }
    public Collection<EMethod> getMethods(){
        return methods;
    }
    public String getClassName(){
        String[] classPath = getClassPath();
        if(classPath !=null && classPath.length>0){
            return classPath[classPath.length-1];
        }
        return null;
    }
    public String getPackage(){
        String[] classPath = getClassPath();
        if(classPath !=null && classPath.length>0){
            String packageName="";
            for(int packageId=0;packageId<classPath.length-1;packageId++){
                packageName +=classPath[packageId];
                if(packageId<classPath.length-2){
                    packageName+=".";
                }
            }return packageName;
        }
        return null;
    }
    public String[] getClassPath(){
        if(getName()!=null){
            String[] classPath = getName().split("\\.");
            return classPath;
        }
        return null;
    }
}
